	server_path = $("#server_path").val();
	$(function() {

				
			
				//editables on first profile page
				// $.fn.editable.defaults.mode = 'inline';
				// $.fn.editableform.loading = "<div class='editableform-loading'><i class='light-blue icon-2x icon-spinner icon-spin'></i></div>";
			 //    $.fn.editableform.buttons = '<button type="submit" class="btn btn-info editable-submit"><i class="icon-ok icon-white"></i></button>'+
			 //                                '<button type="button" class="btn editable-cancel"><i class="icon-remove"></i></button>';    
				
				//editables 
			    
			
				
			
			
				$("#state").css('width','200px').select2()
				$("#city").css('width','200px').select2();

				
				
				//var $range = document.createElement("INPUT");
				//$range.type = 'range';
			   
			
				
				
				
				
				// *** editable avatar *** //
				try {//ie8 throws some harmless exception, so let's catch it
			
					//it seems that editable plugin calls appendChild, and as Image doesn't have it, it causes errors on IE at unpredicted points
					//so let's have a fake appendChild for it!
					if( /msie\s*(8|7|6)/.test(navigator.userAgent.toLowerCase()) ) Image.prototype.appendChild = function(el){}
			
					var last_gritter
					
				}catch(e) {}
				
				
				$('#user-profile-3')
				.find('input[type=file]').ace_file_input({
					style:'well',
					btn_choose:'Change avatar',
					btn_change:null,
					no_icon:'icon-picture',
					thumbnail:'large',
					droppable:true,
					before_change: function(files, dropped) {
						var file = files[0];
						if(typeof file === "string") {//files is just a file name here (in browsers that don't support FileReader API)
							if(! (/\.(jpe?g|png|gif)$/i).test(file) ) return false;
						}
						else {//file is a File object
							var type = $.trim(file.type);
							if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif)$/i).test(type) )
									|| ( type.length == 0 && ! (/\.(jpe?g|png|gif)$/i).test(file.name) )//for android default browser!
								) return false;
			
							if( file.size > 110000 ) {//~100Kb
								return false;
							}
						}
			
						return true;
					}
				})
				.end().find('button[type=reset]').on(ace.click_event, function(){
					$('#user-profile-3 input[type=file]').ace_file_input('reset_input');
				})
				.end().find('.date-picker').datepicker().next().on(ace.click_event, function(){
					$(this).prev().focus();
				})
				$('.input-mask-phone').mask('(999) 999-9999');
			
			
			
				////////////////////
				//change profile
				$('[data-toggle="buttons-radio"]').on('click', function(e){
					var target = $(e.target);
					var which = parseInt($.trim(target.text()));
					$('.user-profile').parent().hide();
					$('#user-profile-'+which).parent().show();
				});
			});

	$(document).ready(function(){
		$("#county").chosen(); 
        
        $('.wysiwyg-editor').ace_wysiwyg({
		toolbar:
		[
		'font',
		null,
		'fontSize',
		null,
		{name:'bold', className:'btn-info'},
		{name:'italic', className:'btn-info'},
		{name:'strikethrough', className:'btn-info'},
		{name:'underline', className:'btn-info'},
		null,
		{name:'insertunorderedlist', className:'btn-success'},
		{name:'insertorderedlist', className:'btn-success'},
		{name:'outdent', className:'btn-purple'},
		{name:'indent', className:'btn-purple'},
		null,
		{name:'justifyleft', className:'btn-primary'},
		{name:'justifycenter', className:'btn-primary'},
		{name:'justifyright', className:'btn-primary'},
		{name:'justifyfull', className:'btn-inverse'},
		null,
		
		null,
		
		null,
		'foreColor',
		null,
		{name:'undo', className:'btn-grey'},
		{name:'redo', className:'btn-grey'}
		]
	}).prev().addClass('wysiwyg-style2');
        
        
	});

	// remake cities on country change
	function make_cities(country_id){
		alert(server_path);
		sendData ='make_cities='+country_id;
		$.ajax({
			type: "POST",
			url: server_path+"admin/libs/company_ajax.php",
			data: sendData,
        // dataType:'json',
        success: function(data){        
        	$(".cities_wrapper").html(data);
        	$("#city").css('width','200px').select2();
        }
    });
	}
	function save_company(){
		data = "save_company=1&"+$("#profile_form").serialize()+'&company_description='+$("#company_description").html()+'&company_url='+$("#company_url").val();
		$.ajax({
			type: "POST",
			url: server_path+"admin/libs/company_ajax.php",
			data: data,
        // dataType:'json',
        success: function(data){        
        	bootbox.alert("Informatiile au fost salvate cu succes!", function() {
             
            });
        }
    });
	}